#pragma once

#include <typedef.h>

#if defined(CONFIG_TAR4ESP32)
#include "driver/spi_master.h"
#endif

class SPI
{
public:
	SPI();
	virtual ~SPI();
	virtual int Transfer(uint8_t addr, uint8_t* send, uint8_t* recv, int len);
	virtual int Write(uint8_t addr, uint8_t* data, uint16_t len);
	virtual int Read(uint8_t addr, uint8_t* data, uint16_t len);

private:
#if defined(CONFIG_TAR4ESP32)
	spi_device_handle_t spi;
	spi_bus_config_t buscfg;
	spi_device_interface_config_t devcfg;
#endif
};